<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      function countDown(time) {
        var nowTime = +new Date();
        var inputTime = +new Date(time);
        var times = (inputTime - nowTime) / 1000;
        var d = parseInt(times / 60 / 60 / 24);
        d = d < 10 ? "0" + d : d;
        var h = parseInt((times / 60 / 60) % 24);
        h = h < 10 ? "0" + h : h;
        var mins = parseInt((times / 60 / 60) % 60);
        mins = mins < 10 ? "0" + mins : mins;
        var s = parseInt(times % 60);
        s = s < 10 ? "0" + s : s;
        return d + "天" + h + "时" + mins + "分" + s + "秒";
      }
      console.log(countDown("2022-10-8 18:00:00"));
    </script>
  </head>
  <body></body>
</html>
